package com.yonyou.cyxdms.sysAuth.service.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.yonyou.cyx.function.utils.jsonserializer.localdatetime.JsonLocalDateTimeDeserializer;
import com.yonyou.cyx.function.utils.jsonserializer.localdatetime.JsonLocalDateTimeSerializer;
import com.yonyou.cyxdms.framework.bean.entity.base.DMSBasePO;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.time.LocalDateTime;

import java.io.Serializable;
import java.util.Date;

import com.yonyou.cyx.function.utils.bean.BeanMapperUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yonyou.cyx.framework.bean.dto.base.BaseDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.user.EmployeeDTO;

/**
 * <p>
 * 经销商员工
 * </p>
 *
 * @author 李贺
 * @since 2019-09-18
 */
@TableName("tm_employee")
public class EmployeePO extends DMSBasePO<EmployeePO> {

    private static final long serialVersionUID = 1L;

    /**
     * 
            
     */
    @TableId(value = "EMPLOYEE_ID", type = IdType.AUTO)
    private Long employeeId;
    /**
     * APP_ID
     */
    @TableField("APP_ID")
    private String appId;
    /**
     * 数据类型
     */
    @TableField("DATA_TYPE")
    private Integer dataType;
    /**
     * 公司ID
     */
    @TableField("COMPANY_ID")
    private Long companyId;
    @TableField("ORG_ID")
    private Long orgId;
    @TableField("EMP_ID")
    private Long empId;
    /**
     * 员工编号（暂时保留）
     */
    @TableField("EMPLOYEE_NO")
    private String employeeNo;
    /**
     * 是否主任职公司
     */
    @TableField("IS_MAJOR")
    private Integer isMajor;
    /**
     * 职务代码
     */
    @TableField("POSITION_CODE")
    private String positionCode;
    /**
     * 班组ID
     */
    @TableField("WORKGROUP_ID")
    private String workgroupId;
    /**
     * 工种ID
     */
    @TableField("WORKER_TYPE_ID")
    private String workerTypeId;
    /**
     * 技师等级
     */
    @TableField("TECHNICIAN_GRADE")
    private String technicianGrade;
    /**
     * 主工位
     */
    @TableField("MAINTAIN_STATION_ID")
    private String maintainStationId;
    /**
     * 副工位
     */
    @TableField("DEPUTY_STATION_ID")
    private String deputyStationId;
    /**
     * 是否临时记录
     */
    @TableField("IS_TEMP")
    private Integer isTemp;
    /**
     * 是否有效
     */
    @TableField("VALID_STATUS")
    private Integer validStatus;
    /**
     * 人员状态:在职，离职
     */
    @TableField("EMPLOYEE_STATUS")
    private Integer employeeStatus;
    /**
     * 离职日期
     */
    @TableField("DIMISSION_DATE")
    private Date dimissionDate;
    /**
     * 数据类型
     */

    /**
     * 来源日期
     */
    @TableField("SOURCE_CHANGED_AT")
    private LocalDateTime sourceChangedAt;
    @TableField("FOUND_DATE")
    private LocalDateTime foundDate;
    @TableField("IS_DELETED")
    @Version
    @TableLogic
    private Integer isDeleted;
    @TableField("IS_ADMIN")
    private Integer isAdmin;
    @TableField("OWNER_CODE")
    private String ownerCode;

    /**
     * 第一岗位
     */
    @TableField("FIRST_POST")
    private Integer firstPost;
    /**
     * 第二岗位
     */
    @TableField("SECOND_POST")
    private Integer secondPost;
    /**
     * 第三岗位
     */
    @TableField("THIRD_POST")
    private Integer thirdPost;
    /**
     * 入职时间
     */
    @TableField("ENTRY_TIME")
    @JsonDeserialize(using = JsonLocalDateTimeDeserializer.class)
    @JsonSerialize(using = JsonLocalDateTimeSerializer.class)
    private LocalDateTime entryTime;

    public EmployeePO() {
        super();
    }

    // 用户更新或者插入
    public EmployeePO(EmployeeDTO employeeDTO) {
        if (employeeDTO.getEmpId() != null) {
            this.setEmployeeId(Long.parseLong(employeeDTO.getEmpId().toString()));
        }
        this.setAppId(employeeDTO.getAppId());
        this.setUpdatedAt(LocalDateTime.now());
        this.setCreatedAt(LocalDateTime.now());
    }

    public String getDeputyStationId() {
        return deputyStationId;
    }

    public void setDeputyStationId(String deputyStationId) {
        this.deputyStationId = deputyStationId;
    }

    public LocalDateTime getEntryTime() {
        return entryTime;
    }

    public void setEntryTime(LocalDateTime entryTime) {
        this.entryTime = entryTime;
    }

    public Integer getFirstPost() {
        return firstPost;
    }

    public void setFirstPost(Integer firstPost) {
        this.firstPost = firstPost;
    }

    public Integer getSecondPost() {
        return secondPost;
    }

    public void setSecondPost(Integer secondPost) {
        this.secondPost = secondPost;
    }

    public Integer getThirdPost() {
        return thirdPost;
    }

    public void setThirdPost(Integer thirdPost) {
        this.thirdPost = thirdPost;
    }

    public Long getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(Long employeeId) {
        this.employeeId = employeeId;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getEmpId() {
        return empId;
    }

    public void setEmpId(Long empId) {
        this.empId = empId;
    }

    public String getEmployeeNo() {
        return employeeNo;
    }

    public void setEmployeeNo(String employeeNo) {
        this.employeeNo = employeeNo;
    }

    public Integer getIsMajor() {
        return isMajor;
    }

    public void setIsMajor(Integer isMajor) {
        this.isMajor = isMajor;
    }

    public String getPositionCode() {
        return positionCode;
    }

    public void setPositionCode(String positionCode) {
        this.positionCode = positionCode;
    }

    public String getWorkgroupId() {
        return workgroupId;
    }

    public void setWorkgroupId(String workgroupId) {
        this.workgroupId = workgroupId;
    }

    public String getWorkerTypeId() {
        return workerTypeId;
    }

    public void setWorkerTypeId(String workerTypeId) {
        this.workerTypeId = workerTypeId;
    }

    public String getTechnicianGrade() {
        return technicianGrade;
    }

    public void setTechnicianGrade(String technicianGrade) {
        this.technicianGrade = technicianGrade;
    }

    public String getMaintainStationId() {
        return maintainStationId;
    }

    public void setMaintainStationId(String maintainStationId) {
        this.maintainStationId = maintainStationId;
    }

    public Integer getIsTemp() {
        return isTemp;
    }

    public void setIsTemp(Integer isTemp) {
        this.isTemp = isTemp;
    }

    public Integer getValidStatus() {
        return validStatus;
    }

    public void setValidStatus(Integer validStatus) {
        this.validStatus = validStatus;
    }

    public Integer getEmployeeStatus() {
        return employeeStatus;
    }

    public void setEmployeeStatus(Integer employeeStatus) {
        this.employeeStatus = employeeStatus;
    }

    public Date getDimissionDate() {
        return dimissionDate;
    }

    public void setDimissionDate(Date dimissionDate) {
        this.dimissionDate = dimissionDate;
    }

    public Integer getDataType() {
        return dataType;
    }

    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }

    public LocalDateTime getSourceChangedAt() {
        return sourceChangedAt;
    }

    public void setSourceChangedAt(LocalDateTime sourceChangedAt) {
        this.sourceChangedAt = sourceChangedAt;
    }

    public LocalDateTime getFoundDate() {
        return foundDate;
    }

    public void setFoundDate(LocalDateTime foundDate) {
        this.foundDate = foundDate;
    }

    @Override
    public Integer getIsDeleted() {
        return isDeleted;
    }

    @Override
    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Integer getIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(Integer isAdmin) {
        this.isAdmin = isAdmin;
    }

    public String getOwnerCode() {
        return ownerCode;
    }

    public void setOwnerCode(String ownerCode) {
        this.ownerCode = ownerCode;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    protected Serializable pkVal() {
        return this.employeeId;
    }

    @Override
    public String toString() {
        return "EmployeePO{" +
                "employeeId=" + employeeId +
                ", appId='" + appId + '\'' +
                ", dataType=" + dataType +
                ", companyId=" + companyId +
                ", orgId=" + orgId +
                ", empId=" + empId +
                ", employeeNo='" + employeeNo + '\'' +
                ", isMajor=" + isMajor +
                ", positionCode='" + positionCode + '\'' +
                ", workgroupId=" + workgroupId +
                ", workerTypeId=" + workerTypeId +
                ", technicianGrade=" + technicianGrade +
                ", maintainStationId=" + maintainStationId +
                ", isTemp=" + isTemp +
                ", validStatus=" + validStatus +
                ", employeeStatus=" + employeeStatus +
                ", dimissionDate=" + dimissionDate +
                ", dataType=" + dataType +
                ", sourceChangedAt=" + sourceChangedAt +
                ", foundDate=" + foundDate +
                ", isDeleted=" + isDeleted +
                ", isAdmin=" + isAdmin +
                ", ownerCode='" + ownerCode + '\'' +
                '}';
    }


    /**
     * 将PO 信息转化为DTO
     *
     * @param dto 需要进行转换的dto
     * @author 李贺
     * @since 2018/7/22 0022
     */
    protected <T extends BaseDTO> void transDtoToPo(T dto) {
        BeanMapperUtil.copyProperties(this, dto, "employeeId");
    }


}
